package ch.kerbtier.malurus.components;

import ch.kerbtier.malurus.coreimpl.CiComponent;
import ch.kerbtier.malurus.models.ComponentModified;
import ch.kerbtier.malurus.models.GenericModel;
import ch.kerbtier.malurus.models.Model;

public class Label<T> extends CiComponent {
	private Model<T> model;

	public Model<T> getModel() {
		return model;
	}

	public void setModel(Model<T> model) {
		this.model = model;
	}

	public static <U> Label<U> create(U value) {
		Model<U> model = new GenericModel<U>();
		model.setValue(value);
		Label<U> label = new Label<U>();
		label.setModel(model);
		model.addListener(new ComponentModified(label));
		return label;
	}

	public static <U> Label<U> create(GenericModel<U> model) {
		Label<U> label = new Label<U>();
		label.setModel(model);
		model.addListener(new ComponentModified(label));
		return label;
	}
}
